package com.k.leetcode;

/**
 * Created by 170623910 on 2020/6/17.
 */
public class StringTest {
    public static String CharAtreverse(String s) {
        System.out.println(s.charAt(0)+":"+s.charAt(1)+":"+s.charAt(2));
        int length = s.length();
        String reverse = "";
        for(int i=0; i<length; i++){

            reverse = s.charAt(i) + reverse;
        }
        return reverse;
    }
    public static String CharAtreverse2(String s) {
        System.out.println(s.charAt(0)+":"+s.charAt(1)+":"+s.charAt(2));
        int length = s.length();
        String reverse = "";
        for(int i=length-1; i>=0; i--){
            System.out.println("loop:"+i);
            reverse = reverse+s.charAt(i);
        }
        return reverse;
    }

    public static void main(String[] args) {
        String r = StringTest.CharAtreverse2("ljw");
        System.out.println(r);
    }
}
